// ['hello', 'gay', 'blob', 'fyi', 'circle', 'rooom', 'zzz'] 按数组第二个字母排序
var arr = ['hello', 'gay', 'blob', 'fyi', 'circle', 'rooom', 'zzz']
function compareSort() {
    var newArr = []
    for (var i = 0; i < arr.length; i++) {
        newArr.push({ id: arr[i][1], origin: arr[i] }) //[{e:hello},{a:gay},{l:blob},{y:fyi}]
    }
    console.log(newArr);
    newArr.sort(function (a, b) {
        var x = a.id // e
        var y = b.id // a
        if (x > y) {
            return 1
        }
        if (x < y) {
            return -1
        }
        return 0
    })
    console.log(newArr)

    var result = []
    for (var j = 0; j < newArr.length; j++) {
        result.push(newArr[j].origin)
    }
    console.log(result)
}
compareSort()
